
#ifndef OSTHREAD_H_INCLUDED
#define OSTHREAD_H_INCLUDED

#define		THREAD_WAIT_EXIT		0
#define		THREAD_WAIT_TIMEOUT		1
#define		THREAD_WAIT_FAILED		2

#ifndef WIN32
	#include <pthread.h>
#else
	#include <windows.h>
#endif

#define THREAD_STATE_NOTSTARTED     0
#define THREAD_STATE_STARTED		1

	typedef struct
	{
	#ifdef WIN32
		HANDLE thread_handle;
	#else
		pthread_t thread_handle;
	#endif
		void * wait_event;
		void * param;
		int	   state;

	}thread_ctx;

#ifdef __cplusplus
	extern "C" {
#endif

	thread_ctx* thread_create1(void * callback, void * lpParam, char * eventName);

	long thread_wait(thread_ctx* ctx, long timeOut);

	long thread_exit(thread_ctx * ctx);

	long thread_quit(thread_ctx * ctx);

	long thread_terminate1(thread_ctx * ctx);

	long thread_sleep(long interval);

	long thread_exist(thread_ctx * ctx, char * eventName);

	long thread_get_tick_count();

   char * thread_get_module_filename();


#ifdef __cplusplus
	}
#endif

#endif
